package com.mxl.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mxl.mapper.UsersMapper;
import com.mxl.model.Users;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UsersServiceImpl {

    @Resource
    UsersMapper usersMapper;

    public Users getUserByName(String username) {
        Users user = usersMapper.selectOne(new QueryWrapper<Users>().eq("username", username));
        if (user == null) {
            throw new UnknownAccountException("用户名不存在!");
        }
        return user;
    }
}
